package com.rogue.order.management.controller;

import com.github.pagehelper.PageInfo;
import com.rogue.common.core.utils.ResultDTO;
import com.rogue.order.management.domain.HsOrder;
import com.rogue.order.management.domain.OrderPageDTO;
import com.rogue.order.management.service.HsOrderService;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author YeaH
 * @create 2022/4/27 21:58
 */
@RestController
@RequestMapping("/order")
public class OrderController {

    @Resource
    private HsOrderService hsOrderService;

    @RequestMapping("/create")
    public ResultDTO create(@RequestBody HsOrder hsOrder){
        return ResultDTO.success(hsOrderService.save(hsOrder));
    }

    @RequestMapping("/update")
    public ResultDTO update(@RequestBody HsOrder hsOrder){
        return ResultDTO.success(hsOrderService.updateById(hsOrder));
    }

    @RequestMapping("/delete/{id}")
    public ResultDTO delete(@PathVariable Long id){
        return ResultDTO.success(hsOrderService.removeById(id));
    }

    @RequestMapping("/get/{id}")
    public ResultDTO get(@PathVariable Long id){
        return ResultDTO.success(hsOrderService.getById(id));
    }

    @RequestMapping("listOrder")
    public ResultDTO<PageInfo<HsOrder>> listOrder(@RequestBody OrderPageDTO orderPageDTO){
        return ResultDTO.success(hsOrderService.listOrder(orderPageDTO));
    }
}
